package com.yzy.fly.config.properties;

import lombok.Data;
import org.apache.commons.collections.MapUtils;

import java.io.Serializable;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

@Data
public class ChannelConfiguration implements Serializable {

    private Map<String,SecretConfiguration> secrets;

    public Map<String, SecretConfiguration> getSecrets() {
        return this.secrets;
    }

    public void setSecrets(final Map<String, SecretConfiguration> secrets) {
        if (MapUtils.isNotEmpty(secrets)) {
            if (secrets instanceof LinkedHashMap) {
                Set<String> identifyKeys = secrets.keySet();
                Map<String,SecretConfiguration> hashMap= new HashMap<>(identifyKeys.size());
                for (String identifyKey : identifyKeys) {
                    hashMap.put(identifyKey,secrets.get(identifyKey));
                }
                this.secrets = hashMap;
            }
//            this.secrets = secrets;
        }
    }
}
